import { PagerType, SectorType } from '@/types';

import { ResponseListType, WordListType } from '@/types/response';
import { del, get, post } from './request';

/** 校验用户输入是否重复 */
export const checkRegisterUserInput = params =>
  post('/user/checkRegisterUserInput', params);

//关注用户或板块（吧）
export const addOrCanelTasteApi = params =>
  post('/taste/addOrCanelTaste', params);
export const selectPageTasteApi = params =>
  post('/taste/selectPageTaste', params);

//用户相关
export const sendEamilCodeApi = email => get('/user/getEmailCode/' + email);
export const accountLoginApi = parmas => get('/user/login', parmas);
export const WXLoginApi = params => post('/wx/login', params, true);
export const registerUserApi = params => post('/user/registerUser', params);
export const getUserOtherInfoApi = kid =>
  get('/user/getUserOtherInfo?kid=' + kid);
export const getUserinfoApi = kid => get('/user/getUserInfo', { kid });
export const cleanUserHistorySearchApi = kid =>
  get('/user/cleanUserHistorySearch', { kid });
export const getUserHistorySearchApi = kid =>
  get('/user/getUserHistorySearch', { kid });
export const searchPostInfosApi = params =>
  post('/post/searchPostInfos', params);
export const saveOrDeleteMemeApi = params =>
  post('/meme/saveOrDeleteMeme', params);
export const updateUserInfoApi = params => post('/user/updateUserInfo', params);

//敏感词管理
export const delWordApi = kid => del('/word/delWord', { kid });
export const editWordApi = (params: WordListType) =>
  post('/word/updateWord', params);
export const addWordApi = params => post('/word/addWord', params);
export const getWordListApi = (
  params: PagerType,
): Promise<ResponseListType<WordListType>> =>
  post<ResponseListType<WordListType>>('/word/selectWordPage', params);

//板块（吧）管理
export const createSectorApi = params =>
  post('/sector/addOrUpdateSector', params);
export const selectSectorPage = params =>
  post<ResponseListType>('/sector/selectSectorPage', params);
export const examineSectorApplyApi = params =>
  post('/sector/examineSectorApply', params);
export const getSectorInfosApi = kid => get('/sector/getSectorInfos', { kid });

//帖子相关
export const submitPostInfoApi = params => post('/post/submitPostInfo', params);

// 消息&评论相关
export const getEmojiListApi = (type = 'emoji') =>
  get('/comment/getEmojiList', { type });
export const getUserEmojiListApi = userId =>
  get('/meme/getUserStarMeme', { userId });

// 系统管理相关
export const saveTagApi = params => post('/tag/saveTag', params);
